home *** CD-ROM | disk | FTP | other *** search
/ Aminet 4 / Aminet 4 - November 1994.iso / aminet / comm / term / term41source.lha / Extras / Source / term-Source.lha / termUploadQueue.c < prev    next >
C/C++ Source or Header  |  1994-08-27  |  31KB  |  1,460 lines

  1. /*
  2. **    termUploadQueue.c
  3. **
  4. **    Upload queue user interface.
  5. **
  6. **    Copyright © 1990-1994 by Olaf `Olsen' Barthel
  7. **        All Rights Reserved
  8. */
  9.  
  10. #include "termGlobal.h"
  11.  
  12. enum    {    GAD_LIST=1000,GAD_NAME,
  13.         GAD_ADD,GAD_REMOVE,GAD_CLEAR,GAD_HIDE,
  14.         GAD_ADD_FILES
  15.     };
  16.  
  17. enum    {    APP_ICON=1,APP_WINDOW=2 };
  18.  
  19. enum    {    TRANSFERMSG_GET_LIST=1,TRANSFERMSG_CHECK_LIST,
  20.         TRANSFERMSG_UPLOAD,TRANSFERMSG_TOGGLE_ICON
  21.     };
  22.  
  23. STATIC struct List    *TransferList;
  24. STATIC struct Node    *TransferNode;
  25. STATIC LONG         TransferOffset,
  26.              TransferCount,
  27.              TransferSignal;
  28. STATIC struct Process    *TransferProcess;
  29. STATIC struct MsgQueue    *TransferQueue;
  30.  
  31.     /* QueuePanel(struct Window *Window):
  32.      *
  33.      *    Create the user interface for the queue panel.
  34.      */
  35.  
  36. STATIC LayoutHandle *
  37. QueuePanel(struct Window *Window)
  38. {
  39.     LayoutHandle *Handle;
  40.  
  41.     TransferNode    = NULL;
  42.     TransferOffset    = -1;
  43.     TransferCount    = GetListSize(TransferList);
  44.  
  45.     if(Handle = LT_CreateHandleTags(Window ? Window -> WScreen : NULL,
  46.         LH_LocaleHook,    &LocaleHook,
  47.     TAG_DONE))
  48.     {
  49.         LT_New(Handle,
  50.             LA_Type,    VERTICAL_KIND,
  51.         TAG_DONE);
  52.         {
  53.             LT_New(Handle,
  54.                 LA_Type,    VERTICAL_KIND,
  55.             TAG_DONE);
  56.             {
  57.                 LT_New(Handle,
  58.                     LA_Type,    LISTVIEW_KIND,
  59.                     LA_LabelID,    MSG_UPLOADQUEUE_FILES_TO_UPLOAD_TXT,
  60.                     LA_LabelPlace,    PLACE_ABOVE,
  61.                     LA_Chars,    30,
  62.                     LA_Lines,    10,
  63.                     LA_ID,        GAD_LIST,
  64.                     LALV_CursorKey,    TRUE,
  65.                     LALV_MaxGrowY,    20,
  66.                     LALV_MaxGrowX,    50,
  67.                     GTLV_Labels,    TransferList,
  68.  
  69.                     Kick30 ? LALV_Link : TAG_IGNORE,NIL_LINK,
  70.                 TAG_DONE);
  71.  
  72.                 LT_New(Handle,
  73.                     LA_Type,    STRING_KIND,
  74.                     LA_ID,        GAD_NAME,
  75.                     GTST_MaxChars,    255,
  76.                     LAST_Picker,    TRUE,
  77.                 TAG_DONE);
  78.  
  79.                 LT_EndGroup(Handle);
  80.             }
  81.  
  82.             LT_New(Handle,
  83.                 LA_Type,    HORIZONTAL_KIND,
  84.                 LA_LabelID,    MSG_V36_0043,
  85.                 LA_SameSize,    TRUE,
  86.             TAG_DONE);
  87.             {
  88.                 LT_New(Handle,
  89.                     LA_Type,    BUTTON_KIND,
  90.                     LA_LabelID,    MSG_ADD_SEVERAL_FILES_TXT,
  91.                     LA_ID,        GAD_ADD_FILES,
  92.                 TAG_DONE);
  93.  
  94.                 LT_New(Handle,
  95.                     LA_Type,    BUTTON_KIND,
  96.                     LA_LabelID,    MSG_UPLOADQUEUE_ADD_TXT,
  97.                     LA_ID,        GAD_ADD,
  98.                 TAG_DONE);
  99.  
  100.                 LT_New(Handle,
  101.                     LA_Type,    BUTTON_KIND,
  102.                     LA_LabelID,    MSG_UPLOADQUEUE_REMOVE_TXT,
  103.                     LA_ID,        GAD_REMOVE,
  104.                     GA_Disabled,    TRUE,
  105.                 TAG_DONE);
  106.  
  107.                 LT_New(Handle,
  108.                     LA_Type,    BUTTON_KIND,
  109.                     LA_LabelID,    MSG_UPLOADQUEUE_CLEAR_TXT,
  110.                     LA_ID,        GAD_CLEAR,
  111.                     GA_Disabled,    !TransferCount,
  112.                 TAG_DONE);
  113.  
  114.                 LT_EndGroup(Handle);
  115.             }
  116.  
  117.             LT_New(Handle,
  118.                 LA_Type,    VERTICAL_KIND,
  119.             TAG_DONE);
  120.             {
  121.                 LT_New(Handle,LA_Type,XBAR_KIND,LAXB_FullSize,TRUE,TAG_DONE);
  122.  
  123.                 LT_EndGroup(Handle);
  124.             }
  125.  
  126.             LT_New(Handle,LA_Type,HORIZONTAL_KIND,
  127.                 LAGR_SameSize,    TRUE,
  128.             TAG_DONE);
  129.             {
  130.                 LT_New(Handle,
  131.                     LA_Type,    BUTTON_KIND,
  132.                     LA_LabelID,    MSG_UPLOADQUEUE_BINARY_UPLOAD_TXT,
  133.                     LA_ID,        UPLOAD_BINARY,
  134.                     LABT_ExtraFat,    TRUE,
  135.                     LABT_ReturnKey,    TRUE,
  136.                     GA_Disabled,    !TransferCount,
  137.                 TAG_DONE);
  138.  
  139.                 LT_New(Handle,
  140.                     LA_Type,    BUTTON_KIND,
  141.                     LA_LabelID,    MSG_UPLOADQUEUE_TEXT_UPLOAD_TXT,
  142.                     LA_ID,        UPLOAD_TEXT,
  143.                     GA_Disabled,    !TransferCount,
  144.                 TAG_DONE);
  145.  
  146.                 LT_New(Handle,
  147.                     LA_Type,    BUTTON_KIND,
  148.                     LA_LabelID,    MSG_UPLOADQUEUE_HIDE_TXT,
  149.                     LA_ID,        GAD_HIDE,
  150.                     LABT_EscKey,    TRUE,
  151.                 TAG_DONE);
  152.  
  153.                 LT_EndGroup(Handle);
  154.             }
  155.  
  156.             LT_EndGroup(Handle);
  157.         }
  158.  
  159.         if(LT_Layout(Handle,LocaleString(MSG_UPLOADQUEUE_FILE_UPLOAD_LIST_TXT),NULL,0,0,IDCMP_CLOSEWINDOW,0,
  160.             WA_DepthGadget,        TRUE,
  161.             WA_CloseGadget,        TRUE,
  162.             WA_DragBar,        TRUE,
  163.             WA_RMBTrap,        TRUE,
  164.             WA_Activate,        TRUE,
  165.             LAWN_BelowMouse,    TRUE,
  166.         TAG_DONE))
  167.         {
  168.             GuideContext(CONTEXT_UPLOAD_QUEUE);
  169.  
  170.             return(Handle);
  171.         }
  172.  
  173.         LT_DeleteHandle(Handle);
  174.     }
  175.  
  176.     return(NULL);
  177. }
  178.  
  179.     /* HandleQueueWindow(LayoutHandle *Handle):
  180.      *
  181.      *    Process queue panel messages.
  182.      */
  183.  
  184. STATIC LONG __regargs
  185. HandleQueueWindow(LayoutHandle *Handle)
  186. {
  187.     struct IntuiMessage    *Message;
  188.     ULONG             MsgClass,
  189.                  MsgQualifier;
  190.     UWORD             MsgCode;
  191.     struct Gadget        *MsgGadget;
  192.  
  193.     struct Node        *Node;
  194.  
  195.     struct Window        *Window = Handle -> Window;
  196.     LONG             Result = 0;
  197.  
  198.     UBYTE              DummyBuffer[MAX_FILENAME_LENGTH],
  199.                 *DummyChar;
  200.     struct FileRequester    *FileRequest;
  201.  
  202.     while(Message = (struct IntuiMessage *)GT_GetIMsg(Window -> UserPort))
  203.     {
  204.         MsgClass    = Message -> Class;
  205.         MsgQualifier    = Message -> Qualifier;
  206.         MsgCode        = Message -> Code;
  207.         MsgGadget    = (struct Gadget *)Message -> IAddress;
  208.  
  209.         GT_ReplyIMsg(Message);
  210.  
  211.         LT_HandleInput(Handle,MsgQualifier,&MsgClass,&MsgCode,&MsgGadget);
  212.  
  213.         if(MsgClass == IDCMP_CLOSEWINDOW)
  214.             Result = GAD_HIDE;
  215.  
  216.         if(MsgClass == IDCMP_IDCMPUPDATE && MsgGadget -> GadgetID == GAD_NAME)
  217.         {
  218.             LT_LockWindow(Window);
  219.  
  220.             SplitFileName(LT_GetString(Handle,GAD_NAME),&DummyChar,DummyBuffer);
  221.  
  222.             if(FileRequest = GetFile(Window,LocaleString(MSG_UPLOADQUEUE_SELECT_FILE_TXT),DummyBuffer,DummyChar,DummyBuffer,NULL,FALSE,FALSE,FALSE,LocaleString(MSG_GLOBAL_SELECT_TXT),FALSE))
  223.             {
  224.                 LT_SetAttributes(Handle,GAD_NAME,
  225.                     GTST_String,    DummyBuffer,
  226.                 TAG_DONE);
  227.             }
  228.  
  229.             LT_UnlockWindow(Window);
  230.  
  231.             LT_Activate(Handle,GAD_NAME);
  232.         }
  233.  
  234.         if(MsgClass == IDCMP_GADGETUP)
  235.         {
  236.             switch(MsgGadget -> GadgetID)
  237.             {
  238.                 case GAD_ADD_FILES:
  239.  
  240.                     LT_LockWindow(Window);
  241.  
  242.                     if(!GetCurrentDirName(DummyBuffer,MAX_FILENAME_LENGTH))
  243.                         DummyBuffer[0] = 0;
  244.  
  245.                     if(FileRequest = AllocAslRequestTags(ASL_FileRequest,
  246.                         ASL_Window,    Window,
  247.                         ASL_Hail,    LocaleString(MSG_ADD_FILES_TITLE_TXT),
  248.                         ASL_FuncFlags,    FILF_MULTISELECT,
  249.                         ASL_OKText,    LocaleString(MSG_ADD_GAD),
  250.                         ASL_CancelText,    LocaleString(MSG_DONE_GAD),
  251.                         ASL_Dir,    DummyBuffer,
  252.                         ASLFR_TextAttr,    &UserFont,
  253.                     TAG_DONE))
  254.                     {
  255.                         LONG i;
  256.  
  257.                         LT_SetAttributes(Handle,GAD_LIST,
  258.                             GTLV_Labels,    ~0,
  259.                         TAG_DONE);
  260.  
  261.                         while(AslRequestTags(FileRequest,TAG_DONE))
  262.                         {
  263.                             for(i = 0 ; i < FileRequest -> rf_NumArgs ; i++)
  264.                             {
  265.                                 if(FileRequest -> fr_ArgList[i] . wa_Lock)
  266.                                 {
  267.                                     if(!NameFromLock(FileRequest -> fr_ArgList[i] . wa_Lock,DummyBuffer,MAX_FILENAME_LENGTH))
  268.                                         DummyBuffer[0] = 0;
  269.                                 }
  270.                                 else
  271.                                     strcpy(DummyBuffer,FileRequest -> fr_Drawer);
  272.  
  273.                                 if(FileRequest -> fr_ArgList[i] . wa_Name)
  274.                                 {
  275.                                     if(!AddPart(DummyBuffer,FileRequest -> fr_ArgList[i] . wa_Name,MAX_FILENAME_LENGTH))
  276.                                         DummyBuffer[0] = 0;
  277.                                 }
  278.  
  279.                                 if(DummyBuffer[0])
  280.                                 {
  281.                                     if(Node = (struct Node *)AllocVecPooled(sizeof(struct Node) + 256,MEMF_ANY))
  282.                                     {
  283.                                         Node -> ln_Name = (STRPTR)(Node + 1);
  284.  
  285.                                         strcpy(Node -> ln_Name,DummyBuffer);
  286.  
  287.                                         AddTail(TransferList,Node);
  288.  
  289.                                         TransferNode = Node;
  290.                                         TransferOffset = TransferCount++;
  291.                                     }
  292.                                 }
  293.                             }
  294.  
  295.                             LT_SetAttributes(Handle,GAD_LIST,
  296.                                 GTLV_Labels,    TransferList,
  297.                                 GTLV_Selected,    TransferOffset,
  298.                             TAG_DONE);
  299.                         }
  300.  
  301.                         LT_SetAttributes(Handle,GAD_LIST,
  302.                             GTLV_Labels,    TransferList,
  303.                             GTLV_Selected,    TransferOffset,
  304.                         TAG_DONE);
  305.  
  306.                         if(TransferCount)
  307.                         {
  308.                             LT_SetAttributes(Handle,GAD_NAME,
  309.                                 GTST_String,    "",
  310.                             TAG_DONE);
  311.  
  312.                             LT_SetAttributes(Handle,GAD_REMOVE,
  313.                                 GA_Disabled,    FALSE,
  314.                             TAG_DONE);
  315.  
  316.                             LT_SetAttributes(Handle,UPLOAD_BINARY,
  317.                                 GA_Disabled,    FALSE,
  318.                             TAG_DONE);
  319.  
  320.                             LT_SetAttributes(Handle,UPLOAD_TEXT,
  321.                                 GA_Disabled,    FALSE,
  322.                             TAG_DONE);
  323.  
  324.                             LT_SetAttributes(Handle,GAD_CLEAR,
  325.                                 GA_Disabled,    FALSE,
  326.                             TAG_DONE);
  327.                         }
  328.  
  329.                         FreeAslRequest(FileRequest);
  330.                     }
  331.  
  332.                     LT_UnlockWindow(Window);
  333.                     break;
  334.  
  335.                 case GAD_ADD:
  336.  
  337.                     if(Node = (struct Node *)AllocVecPooled(sizeof(struct Node) + 256,MEMF_ANY))
  338.                     {
  339.                         Node -> ln_Name = (STRPTR)(Node + 1);
  340.  
  341.                         Node -> ln_Name[0] = 0;
  342.  
  343.                         LT_SetAttributes(Handle,GAD_LIST,
  344.                             GTLV_Labels,    ~0,
  345.                         TAG_DONE);
  346.  
  347.                         AddTail(TransferList,Node);
  348.  
  349.                         LT_SetAttributes(Handle,GAD_LIST,
  350.                             GTLV_Labels,    TransferList,
  351.                             GTLV_Selected,    TransferOffset = TransferCount++,
  352.                         TAG_DONE);
  353.  
  354.                         LT_SetAttributes(Handle,GAD_NAME,
  355.                             GTST_String,    "",
  356.                         TAG_DONE);
  357.  
  358.                         LT_SetAttributes(Handle,GAD_REMOVE,
  359.                             GA_Disabled,    FALSE,
  360.                         TAG_DONE);
  361.  
  362.                         LT_SetAttributes(Handle,UPLOAD_BINARY,
  363.                             GA_Disabled,    FALSE,
  364.                         TAG_DONE);
  365.  
  366.                         LT_SetAttributes(Handle,UPLOAD_TEXT,
  367.                             GA_Disabled,    FALSE,
  368.                         TAG_DONE);
  369.  
  370.                         LT_SetAttributes(Handle,GAD_CLEAR,
  371.                             GA_Disabled,    FALSE,
  372.                         TAG_DONE);
  373.  
  374.                         TransferNode = Node;
  375.  
  376.                         LT_Activate(Handle,GAD_NAME);
  377.                     }
  378.                     else
  379.                         DisplayBeep(Window -> WScreen);
  380.  
  381.                     break;
  382.  
  383.                 case GAD_REMOVE:
  384.  
  385.                     if(TransferNode)
  386.                     {
  387.                         LT_SetAttributes(Handle,GAD_LIST,
  388.                             GTLV_Labels,    ~0,
  389.                         TAG_DONE);
  390.  
  391.                         if(--TransferCount)
  392.                         {
  393.                             if(TransferNode -> ln_Succ -> ln_Succ)
  394.                                 Node = TransferNode -> ln_Succ;
  395.                             else
  396.                             {
  397.                                 if(TransferNode -> ln_Pred -> ln_Pred)
  398.                                 {
  399.                                     Node = TransferNode -> ln_Pred;
  400.  
  401.                                     TransferOffset--;
  402.                                 }
  403.                                 else
  404.                                 {
  405.                                     TransferOffset = -1;
  406.  
  407.                                     Node = NULL;
  408.                                 }
  409.                             }
  410.                         }
  411.                         else
  412.                         {
  413.                             TransferOffset = -1;
  414.  
  415.                             Node = NULL;
  416.                         }
  417.  
  418.                         Remove(TransferNode);
  419.  
  420.                         FreeVecPooled(TransferNode);
  421.  
  422.                         TransferNode = Node;
  423.  
  424.                         LT_SetAttributes(Handle,GAD_LIST,
  425.                             GTLV_Labels,    TransferList,
  426.                             GTLV_Selected,    TransferOffset,
  427.                         TAG_DONE);
  428.  
  429.                         if(!TransferCount)
  430.                         {
  431.                             LT_SetAttributes(Handle,GAD_REMOVE,
  432.                                 GA_Disabled,    TRUE,
  433.                             TAG_DONE);
  434.  
  435.                             LT_SetAttributes(Handle,GAD_NAME,
  436.                                 GTST_String,    "",
  437.                             TAG_DONE);
  438.  
  439.                             LT_SetAttributes(Handle,GAD_CLEAR,
  440.                                 GA_Disabled,    TRUE,
  441.                             TAG_DONE);
  442.  
  443.                             LT_SetAttributes(Handle,UPLOAD_BINARY,
  444.                                 GA_Disabled,    TRUE,
  445.                             TAG_DONE);
  446.  
  447.                             LT_SetAttributes(Handle,UPLOAD_TEXT,
  448.                                 GA_Disabled,    TRUE,
  449.                             TAG_DONE);
  450.                         }
  451.                         else
  452.                         {
  453.                             LT_SetAttributes(Handle,GAD_NAME,
  454.                                 GTST_String,    TransferNode -> ln_Name,
  455.                             TAG_DONE);
  456.                         }
  457.                     }
  458.  
  459.                     break;
  460.  
  461.                 case GAD_LIST:
  462.  
  463.                     if(TransferNode = (struct Node *)GetListNode(MsgCode,TransferList))
  464.                     {
  465.                         TransferOffset = MsgCode;
  466.  
  467.                         LT_SetAttributes(Handle,GAD_NAME,
  468.                             GTST_String,    TransferNode -> ln_Name,
  469.                         TAG_DONE);
  470.  
  471.                         LT_SetAttributes(Handle,GAD_REMOVE,
  472.                             GA_Disabled,    FALSE,
  473.                         TAG_DONE);
  474.                     }
  475.  
  476.                     break;
  477.  
  478.                 case GAD_NAME:
  479.  
  480.                     if(TransferNode)
  481.                     {
  482.                         LT_SetAttributes(Handle,GAD_LIST,
  483.                             GTLV_Labels,    ~0,
  484.                         TAG_DONE);
  485.  
  486.                         strcpy(TransferNode -> ln_Name,LT_GetString(Handle,GAD_NAME));
  487.  
  488.                         LT_SetAttributes(Handle,GAD_LIST,
  489.                             GTLV_Labels,    TransferList,
  490.                             GTLV_Selected,    ~0,
  491.                         TAG_DONE);
  492.                     }
  493.                     else
  494.                     {
  495.                         if(Node = (struct Node *)AllocVecPooled(sizeof(struct Node) + 256,MEMF_ANY))
  496.                         {
  497.                             Node -> ln_Name = (STRPTR)(Node + 1);
  498.  
  499.                             strcpy(Node -> ln_Name,LT_GetString(Handle,GAD_NAME));
  500.  
  501.                             LT_SetAttributes(Handle,GAD_LIST,
  502.                                 GTLV_Labels,    ~0,
  503.                             TAG_DONE);
  504.  
  505.                             AddTail(TransferList,Node);
  506.  
  507.                             TransferCount++;
  508.  
  509.                             LT_SetAttributes(Handle,UPLOAD_BINARY,
  510.                                 GA_Disabled,    FALSE,
  511.                             TAG_DONE);
  512.  
  513.                             LT_SetAttributes(Handle,UPLOAD_TEXT,
  514.                                 GA_Disabled,    FALSE,
  515.                             TAG_DONE);
  516.  
  517.                             LT_SetAttributes(Handle,GAD_CLEAR,
  518.                                 GA_Disabled,    FALSE,
  519.                             TAG_DONE);
  520.  
  521.                             LT_SetAttributes(Handle,GAD_LIST,
  522.                                 GTLV_Labels,        TransferList,
  523.                                 GTLV_Selected,        ~0,
  524.                                 GTLV_MakeVisible,    TransferCount - 1,
  525.                             TAG_DONE);
  526.                         }
  527.                     }
  528.  
  529.                     LT_SetAttributes(Handle,GAD_REMOVE,
  530.                         GA_Disabled,    TRUE,
  531.                     TAG_DONE);
  532.  
  533.                     LT_SetAttributes(Handle,GAD_NAME,
  534.                         GTST_String,    "",
  535.                     TAG_DONE);
  536.  
  537.                     TransferNode    = NULL;
  538.                     TransferOffset    = -1;
  539.  
  540.                     break;
  541.  
  542.                 case GAD_CLEAR:
  543.  
  544.                     LT_SetAttributes(Handle,GAD_LIST,
  545.                         GTLV_Labels,    ~0,
  546.                     TAG_DONE);
  547.  
  548.                     TransferCount    = 0;
  549.                     TransferOffset    = -1;
  550.                     TransferNode    = NULL;
  551.  
  552.                     FreeList(TransferList);
  553.  
  554.                     LT_SetAttributes(Handle,GAD_REMOVE,
  555.                         GA_Disabled,    TRUE,
  556.                     TAG_DONE);
  557.  
  558.                     LT_SetAttributes(Handle,GAD_NAME,
  559.                         GTST_String,    "",
  560.                     TAG_DONE);
  561.  
  562.                     LT_SetAttributes(Handle,GAD_CLEAR,
  563.                         GA_Disabled,    TRUE,
  564.                     TAG_DONE);
  565.  
  566.                     LT_SetAttributes(Handle,UPLOAD_BINARY,
  567.                         GA_Disabled,    TRUE,
  568.                     TAG_DONE);
  569.  
  570.                     LT_SetAttributes(Handle,UPLOAD_TEXT,
  571.                         GA_Disabled,    TRUE,
  572.                     TAG_DONE);
  573.  
  574.                     LT_SetAttributes(Handle,GAD_LIST,
  575.                         GTLV_Labels,    TransferList,
  576.                         GTLV_Selected,    ~0,
  577.                     TAG_DONE);
  578.  
  579.                     break;
  580.  
  581.                 case UPLOAD_BINARY:
  582.                 case UPLOAD_TEXT:
  583.                 case GAD_HIDE:
  584.  
  585.                     Result = MsgGadget -> GadgetID;
  586.                     break;
  587.             }
  588.         }
  589.     }
  590.  
  591.     return(Result);
  592. }
  593.  
  594.     /* QueueClientDestructor(struct DataMsg *Item):
  595.      *
  596.      *    Local msgitem destructor.
  597.      */
  598.  
  599. STATIC VOID __stdargs
  600. QueueClientDestructor(struct DataMsg *Item)
  601. {
  602.     Signal(TransferProcess,1L << TransferSignal);
  603. }
  604.  
  605.     /* QueueEntry(VOID):
  606.      *
  607.      *    The entry point for the queue process.
  608.      */
  609.  
  610. STATIC VOID __saveds
  611. QueueEntry(VOID)
  612. {
  613.     if(TransferList = (struct List *)AllocVecPooled(sizeof(struct List),MEMF_ANY))
  614.     {
  615.         if(TransferQueue = CreateMsgQueue(NULL,0))
  616.         {
  617.             struct MsgPort        *AppPort;
  618.             struct AppIcon        *AppIcon;
  619.             struct AppWindow    *AppWindow;
  620.             APTR             OldPtr;
  621.  
  622.             NewList(TransferList);
  623.  
  624.             TransferNode    = NULL;
  625.             TransferOffset    = -1;
  626.  
  627.             if(AppPort = CreateMsgPort())
  628.             {
  629.                 if((TransferSignal = AllocSignal(-1)) != -1)
  630.                 {
  631.                     ULONG             Signals;
  632.                     BOOLEAN             Done = FALSE;
  633.                     LayoutHandle        *Handle;
  634.                     struct Window        *LocalWindow;
  635.                     ULONG             WindowMask,
  636.                                  TransferMask,
  637.                                  ClientMask;
  638.                     struct AppMessage    *AppMessage;
  639.                     struct DiskObject    *LoadedIcon = NULL;
  640.  
  641.                     if(WorkbenchBase && !Config -> MiscConfig -> HideUploadIcon)
  642.                     {
  643.                         if(IconBase)
  644.                         {
  645.                             UBYTE LocalBuffer[MAX_FILENAME_LENGTH];
  646.  
  647.                             strcpy(LocalBuffer,Config -> PathConfig -> DefaultStorage);
  648.  
  649.                             if(AddPart(LocalBuffer,"term_DropIcon",MAX_FILENAME_LENGTH))
  650.                                 LoadedIcon = GetDiskObject(LocalBuffer);
  651.  
  652.                             if(!LoadedIcon)
  653.                                 LoadedIcon = GetDiskObject("PROGDIR:term_DropIcon");
  654.                         }
  655.  
  656.                         AppIcon = AddAppIconA(APP_ICON,NULL,LocaleString(MSG_UPLOADQUEUE_TERM_UPLOAD_LIST_TXT),AppPort,NULL,LoadedIcon ? LoadedIcon : &DropIcon,NULL);
  657.                     }
  658.                     else
  659.                         AppIcon = NULL;
  660.  
  661.                     AppWindow    = NULL;
  662.                     WindowMask    = NULL;
  663.                     Handle        = NULL;
  664.                     LocalWindow    = NULL;
  665.                     TransferMask    = TransferQueue -> SigMask;
  666.                     ClientMask    = (1L << TransferSignal);
  667.  
  668.                     TransferProcess = (struct Process *)FindTask(NULL);
  669.  
  670.                     OldPtr = TransferProcess -> pr_WindowPtr;
  671.  
  672.                     Signal(ThisProcess,SIG_HANDSHAKE);
  673.  
  674.                     do
  675.                     {
  676.                         Signals = Wait(SIG_KILL | SIG_SHOW | SIG_HIDE | SIG_GOAWAY | WindowMask | TransferMask | PORTMASK(AppPort));
  677.  
  678.                         if(Signals & TransferMask)
  679.                         {
  680.                             struct DataMsg *Item;
  681.  
  682.                             while(Item = GetMsgItem(TransferQueue))
  683.                             {
  684.                                 switch(Item -> Type)
  685.                                 {
  686.                                     case TRANSFERMSG_GET_LIST:
  687.  
  688.                                         Item -> Data = NULL;
  689.  
  690.                                         if(TransferList -> lh_Head -> ln_Succ)
  691.                                         {
  692.                                             struct List *List;
  693.  
  694.                                             if(Handle)
  695.                                             {
  696.                                                 LT_SetAttributes(Handle,GAD_LIST,
  697.                                                     GTLV_Labels,    ~0,
  698.                                                 TAG_DONE);
  699.                                             }
  700.  
  701.                                             if(List = (struct List *)AllocVecPooled(sizeof(struct List),MEMF_ANY))
  702.                                             {
  703.                                                 struct Node *Node,*Next;
  704.  
  705.                                                 NewList(List);
  706.  
  707.                                                 for(Node = TransferList -> lh_Head ; Next = Node -> ln_Succ ; Node = Next)
  708.                                                 {
  709.                                                     Remove(Node);
  710.  
  711.                                                     AddTail(List,Node);
  712.                                                 }
  713.  
  714.                                                 Item -> Data = (UBYTE *)List;
  715.                                             }
  716.  
  717.                                             if(Handle)
  718.                                             {
  719.                                                 TransferCount = GetListSize(TransferList);
  720.  
  721.                                                 TransferOffset    = -1;
  722.                                                 TransferNode    = NULL;
  723.  
  724.                                                 LT_SetAttributes(Handle,GAD_REMOVE,
  725.                                                     GA_Disabled,    TRUE,
  726.                                                 TAG_DONE);
  727.  
  728.                                                 LT_SetAttributes(Handle,GAD_NAME,
  729.                                                     GTST_String,    "",
  730.                                                 TAG_DONE);
  731.  
  732.                                                 LT_SetAttributes(Handle,GAD_CLEAR,
  733.                                                     GA_Disabled,    !TransferCount,
  734.                                                 TAG_DONE);
  735.  
  736.                                                 LT_SetAttributes(Handle,UPLOAD_BINARY,
  737.                                                     GA_Disabled,    !TransferCount,
  738.                                                 TAG_DONE);
  739.  
  740.                                                 LT_SetAttributes(Handle,UPLOAD_TEXT,
  741.                                                     GA_Disabled,    !TransferCount,
  742.                                                 TAG_DONE);
  743.  
  744.                                                 LT_SetAttributes(Handle,GAD_LIST,
  745.                                                     GTLV_Labels,    TransferList,
  746.                                                 TAG_DONE);
  747.                                             }
  748.                                         }
  749.  
  750.                                         break;
  751.  
  752.                                         // Check to see if there is anything in the list?
  753.  
  754.                                     case TRANSFERMSG_CHECK_LIST:
  755.  
  756.                                         if(TransferList -> lh_Head -> ln_Succ)
  757.                                             Item -> Size = TRUE;
  758.                                         else
  759.                                             Item -> Size = FALSE;
  760.  
  761.                                         break;
  762.  
  763.                                         // Start a file tansfer?
  764.  
  765.                                     case TRANSFERMSG_UPLOAD:
  766.                                     {
  767.                                         UBYTE        Type = Item -> Size;
  768.                                         struct DataMsg    Msg;
  769.  
  770.                                         DeleteMsgItem(Item);
  771.  
  772.                                         Item = NULL;
  773.  
  774.                                         InitMsgItem(&Msg,QueueClientDestructor);
  775.  
  776.                                         Msg . Type = DATAMSGTYPE_UPLOAD;
  777.                                         Msg . Data = (UBYTE *)TransferList;
  778.                                         Msg . Size = Type;
  779.  
  780.                                         if(Handle)
  781.                                         {
  782.                                             LT_SetAttributes(Handle,GAD_LIST,
  783.                                                 GTLV_Labels,    ~0,
  784.                                             TAG_DONE);
  785.  
  786.                                             LT_LockWindow(LocalWindow);
  787.                                         }
  788.  
  789.                                         Forbid();
  790.  
  791.                                         ClrSignal(ClientMask);
  792.  
  793.                                         PutMsgItem(SpecialQueue,(struct MsgItem *)&Msg);
  794.  
  795.                                         Wait(ClientMask);
  796.  
  797.                                         Permit();
  798.  
  799.                                         if(Handle)
  800.                                         {
  801.                                             TransferCount = GetListSize(TransferList);
  802.  
  803.                                             TransferOffset    = -1;
  804.                                             TransferNode    = NULL;
  805.  
  806.                                             LT_SetAttributes(Handle,GAD_REMOVE,
  807.                                                 GA_Disabled,    TRUE,
  808.                                             TAG_DONE);
  809.  
  810.                                             LT_SetAttributes(Handle,GAD_NAME,
  811.                                                 GTST_String,    "",
  812.                                             TAG_DONE);
  813.  
  814.                                             LT_SetAttributes(Handle,GAD_CLEAR,
  815.                                                 GA_Disabled,    !TransferCount,
  816.                                             TAG_DONE);
  817.  
  818.                                             LT_SetAttributes(Handle,UPLOAD_BINARY,
  819.                                                 GA_Disabled,    !TransferCount,
  820.                                             TAG_DONE);
  821.  
  822.                                             LT_SetAttributes(Handle,UPLOAD_TEXT,
  823.                                                 GA_Disabled,    !TransferCount,
  824.                                             TAG_DONE);
  825.  
  826.                                             LT_SetAttributes(Handle,GAD_LIST,
  827.                                                 GTLV_Labels,    TransferList,
  828.                                             TAG_DONE);
  829.  
  830.                                             LT_UnlockWindow(LocalWindow);
  831.                                         }
  832.  
  833.                                         break;
  834.                                     }
  835.  
  836.                                         // Show or hide the icon?
  837.  
  838.                                     case TRANSFERMSG_TOGGLE_ICON:
  839.  
  840.                                             // Hide the icon
  841.  
  842.                                         if(Item -> Size)
  843.                                         {
  844.                                             if(AppIcon)
  845.                                             {
  846.                                                 RemoveAppIcon(AppIcon);
  847.  
  848.                                                 AppIcon = NULL;
  849.                                             }
  850.  
  851.                                             if(LoadedIcon)
  852.                                             {
  853.                                                 FreeDiskObject(LoadedIcon);
  854.  
  855.                                                 LoadedIcon = NULL;
  856.                                             }
  857.                                         }
  858.                                         else
  859.                                         {
  860.                                             if(!AppIcon)
  861.                                             {
  862.                                                 if(WorkbenchBase)
  863.                                                 {
  864.                                                     if(IconBase)
  865.                                                     {
  866.                                                         UBYTE LocalBuffer[MAX_FILENAME_LENGTH];
  867.  
  868.                                                         strcpy(LocalBuffer,Config -> PathConfig -> DefaultStorage);
  869.  
  870.                                                         if(AddPart(LocalBuffer,"term_DropIcon",MAX_FILENAME_LENGTH))
  871.                                                             LoadedIcon = GetDiskObject(LocalBuffer);
  872.  
  873.                                                         if(!LoadedIcon)
  874.                                                             LoadedIcon = GetDiskObject("PROGDIR:term_DropIcon");
  875.                                                     }
  876.  
  877.                                                     AppIcon = AddAppIconA(APP_ICON,NULL,LocaleString(MSG_UPLOADQUEUE_TERM_UPLOAD_LIST_TXT),AppPort,NULL,LoadedIcon ? LoadedIcon : &DropIcon,NULL);
  878.                                                 }
  879.                                                 else
  880.                                                     AppIcon = NULL;
  881.                                             }
  882.                                         }
  883.  
  884.                                         break;
  885.                                 }
  886.  
  887.                                 DeleteMsgItem(Item);
  888.                             }
  889.                         }
  890.  
  891.                         if(Signals & SIG_HIDE)
  892.                         {
  893.                             if(AppWindow)
  894.                             {
  895.                                 RemoveAppWindow(AppWindow);
  896.  
  897.                                 AppWindow = NULL;
  898.                             }
  899.  
  900.                             if(Handle)
  901.                             {
  902.                                 LT_DeleteHandle(Handle);
  903.  
  904.                                 Handle = NULL;
  905.                             }
  906.  
  907.                             WindowMask    = NULL;
  908.                             LocalWindow    = NULL;
  909.  
  910.                             TransferProcess -> pr_WindowPtr = OldPtr;
  911.  
  912.                             Signal(ThisProcess,SIG_HANDSHAKE);
  913.                         }
  914.  
  915.                         if(Signals & SIG_GOAWAY)
  916.                         {
  917.                             if(Handle)
  918.                             {
  919.                                 if(LocalWindow -> WScreen == Screen)
  920.                                 {
  921.                                     if(AppWindow)
  922.                                     {
  923.                                         RemoveAppWindow(AppWindow);
  924.  
  925.                                         AppWindow = NULL;
  926.                                     }
  927.  
  928.                                     LT_DeleteHandle(Handle);
  929.  
  930.                                     Handle        = NULL;
  931.                                     WindowMask    = NULL;
  932.                                     LocalWindow    = NULL;
  933.  
  934.                                     TransferProcess -> pr_WindowPtr = OldPtr;
  935.                                 }
  936.                             }
  937.  
  938.                             Signal(ThisProcess,SIG_HANDSHAKE);
  939.                         }
  940.  
  941.                         if(Signals & SIG_KILL)
  942.                             break;
  943.  
  944.                         if(Signals & SIG_SHOW)
  945.                         {
  946.                             if(!Handle)
  947.                             {
  948.                                 Forbid();
  949.  
  950.                                 if(Handle = QueuePanel(Window))
  951.                                 {
  952.                                     Permit();
  953.  
  954.                                     if(WorkbenchBase)
  955.                                         AppWindow = AddAppWindowA(APP_WINDOW,NULL,Handle -> Window,AppPort,NULL);
  956.                                     else
  957.                                         AppWindow = NULL;
  958.  
  959.                                     LocalWindow    = Handle -> Window;
  960.                                     WindowMask    = PORTMASK(LocalWindow -> UserPort);
  961.  
  962.                                     TransferProcess -> pr_WindowPtr = LocalWindow;
  963.                                 }
  964.                                 else
  965.                                     Permit();
  966.                             }
  967.  
  968.                             if(Handle)
  969.                                 LT_ShowWindow(Handle,TRUE);
  970.                         }
  971.  
  972.                         if(Signals & WindowMask)
  973.                         {
  974.                             struct DataMsg    Msg;
  975.                             LONG        Type;
  976.  
  977.                             switch(Type = HandleQueueWindow(Handle))
  978.                             {
  979.                                 case GAD_HIDE:
  980.  
  981.                                     if(AppWindow)
  982.                                     {
  983.                                         RemoveAppWindow(AppWindow);
  984.  
  985.                                         AppWindow = NULL;
  986.                                     }
  987.  
  988.                                     if(Handle)
  989.                                     {
  990.                                         LT_DeleteHandle(Handle);
  991.  
  992.                                         Handle = NULL;
  993.                                     }
  994.  
  995.                                     TransferProcess -> pr_WindowPtr = OldPtr;
  996.  
  997.                                     WindowMask    = NULL;
  998.                                     LocalWindow    = NULL;
  999.  
  1000.                                     break;
  1001.  
  1002.                                 case UPLOAD_BINARY:
  1003.                                 case UPLOAD_TEXT:
  1004.  
  1005.                                     InitMsgItem(&Msg,QueueClientDestructor);
  1006.  
  1007.                                     Msg . Type = DATAMSGTYPE_UPLOAD;
  1008.                                     Msg . Data = (UBYTE *)TransferList;
  1009.                                     Msg . Size = Type;
  1010.  
  1011.                                     if(Handle)
  1012.                                     {
  1013.                                         LT_SetAttributes(Handle,GAD_LIST,
  1014.                                             GTLV_Labels,    ~0,
  1015.                                         TAG_DONE);
  1016.  
  1017.                                         LT_LockWindow(LocalWindow);
  1018.                                     }
  1019.  
  1020.                                     Forbid();
  1021.  
  1022.                                     ClrSignal(ClientMask);
  1023.  
  1024.                                     PutMsgItem(SpecialQueue,(struct MsgItem *)&Msg);
  1025.  
  1026.                                     Wait(ClientMask);
  1027.  
  1028.                                     Permit();
  1029.  
  1030.                                     if(Handle)
  1031.                                     {
  1032.                                         TransferCount = GetListSize(TransferList);
  1033.  
  1034.                                         TransferOffset    = -1;
  1035.                                         TransferNode    = NULL;
  1036.  
  1037.                                         LT_SetAttributes(Handle,GAD_REMOVE,
  1038.                                             GA_Disabled,    TRUE,
  1039.                                         TAG_DONE);
  1040.  
  1041.                                         LT_SetAttributes(Handle,GAD_NAME,
  1042.                                             GTST_String,    "",
  1043.                                         TAG_DONE);
  1044.  
  1045.                                         LT_SetAttributes(Handle,GAD_CLEAR,
  1046.                                             GA_Disabled,    !TransferCount,
  1047.                                         TAG_DONE);
  1048.  
  1049.                                         LT_SetAttributes(Handle,UPLOAD_BINARY,
  1050.                                             GA_Disabled,    !TransferCount,
  1051.                                         TAG_DONE);
  1052.  
  1053.                                         LT_SetAttributes(Handle,UPLOAD_TEXT,
  1054.                                             GA_Disabled,    !TransferCount,
  1055.                                         TAG_DONE);
  1056.  
  1057.                                         LT_SetAttributes(Handle,GAD_LIST,
  1058.                                             GTLV_Labels,    TransferList,
  1059.                                         TAG_DONE);
  1060.  
  1061.                                         LT_UnlockWindow(LocalWindow);
  1062.                                     }
  1063.  
  1064.                                     break;
  1065.                             }
  1066.                         }
  1067.  
  1068.                         if(Signals & PORTMASK(AppPort))
  1069.                         {
  1070.                             while(AppMessage = (struct AppMessage *)GetMsg(AppPort))
  1071.                             {
  1072.                                 if(AppMessage -> am_Type == AMTYPE_APPWINDOW && Handle)
  1073.                                 {
  1074.                                     UBYTE    DummyBuffer[MAX_FILENAME_LENGTH];
  1075.                                     BPTR    OldDir,FileLock;
  1076.                                     LONG    i;
  1077.  
  1078.                                     TransferProcess -> pr_WindowPtr = (APTR)-1;
  1079.  
  1080.                                     LT_SetAttributes(Handle,GAD_LIST,
  1081.                                         GTLV_Labels,    ~0,
  1082.                                     TAG_DONE);
  1083.  
  1084.                                     for(i = 0 ; i < AppMessage -> am_NumArgs ; i++)
  1085.                                     {
  1086.                                         if(AppMessage -> am_ArgList[i] . wa_Name)
  1087.                                         {
  1088.                                             OldDir = CurrentDir(AppMessage -> am_ArgList[i] . wa_Lock);
  1089.  
  1090.                                             if(GetFileSize(AppMessage -> am_ArgList[i] . wa_Name))
  1091.                                             {
  1092.                                                 if(FileLock = Lock(AppMessage -> am_ArgList[i] . wa_Name,ACCESS_READ))
  1093.                                                 {
  1094.                                                     if(NameFromLock(FileLock,DummyBuffer,MAX_FILENAME_LENGTH))
  1095.                                                     {
  1096.                                                         struct Node *Node;
  1097.  
  1098.                                                         if(Node = (struct Node *)AllocVecPooled(sizeof(struct Node) + 256,MEMF_ANY))
  1099.                                                         {
  1100.                                                             Node -> ln_Name = (STRPTR)(Node + 1);
  1101.  
  1102.                                                             strcpy(Node -> ln_Name,DummyBuffer);
  1103.  
  1104.                                                             AddTail(TransferList,Node);
  1105.  
  1106.                                                             TransferCount++;
  1107.                                                         }
  1108.                                                     }
  1109.  
  1110.                                                     UnLock(FileLock);
  1111.                                                 }
  1112.                                             }
  1113.  
  1114.                                             CurrentDir(OldDir);
  1115.                                         }
  1116.                                     }
  1117.  
  1118.                                     TransferProcess -> pr_WindowPtr = LocalWindow;
  1119.  
  1120.                                     LT_SetAttributes(Handle,GAD_LIST,
  1121.                                         GTLV_Labels,    TransferList,
  1122.                                     TAG_DONE);
  1123.  
  1124.                                     LT_SetAttributes(Handle,GAD_CLEAR,
  1125.                                         GA_Disabled,    !TransferCount,
  1126.                                     TAG_DONE);
  1127.  
  1128.                                     LT_SetAttributes(Handle,UPLOAD_BINARY,
  1129.                                         GA_Disabled,    !TransferCount,
  1130.                                     TAG_DONE);
  1131.  
  1132.                                     LT_SetAttributes(Handle,UPLOAD_TEXT,
  1133.                                         GA_Disabled,    !TransferCount,
  1134.                                     TAG_DONE);
  1135.                                 }
  1136.  
  1137.                                 if(AppMessage -> am_Type == AMTYPE_APPICON)
  1138.                                 {
  1139.                                     if(AppMessage -> am_NumArgs)
  1140.                                     {
  1141.                                         UBYTE    DummyBuffer[MAX_FILENAME_LENGTH];
  1142.                                         BPTR    OldDir,FileLock;
  1143.                                         LONG    i;
  1144.  
  1145.                                         TransferProcess -> pr_WindowPtr = (APTR)-1;
  1146.  
  1147.                                         if(Handle)
  1148.                                         {
  1149.                                             LT_SetAttributes(Handle,GAD_LIST,
  1150.                                                 GTLV_Labels,    ~0,
  1151.                                             TAG_DONE);
  1152.                                         }
  1153.  
  1154.                                         for(i = 0 ; i < AppMessage -> am_NumArgs ; i++)
  1155.                                         {
  1156.                                             if(AppMessage -> am_ArgList[i] . wa_Name)
  1157.                                             {
  1158.                                                 OldDir = CurrentDir(AppMessage -> am_ArgList[i] . wa_Lock);
  1159.  
  1160.                                                 if(GetFileSize(AppMessage -> am_ArgList[i] . wa_Name))
  1161.                                                 {
  1162.                                                     if(FileLock = Lock(AppMessage -> am_ArgList[i] . wa_Name,ACCESS_READ))
  1163.                                                     {
  1164.                                                         if(NameFromLock(FileLock,DummyBuffer,MAX_FILENAME_LENGTH))
  1165.                                                         {
  1166.                                                             struct Node *Node;
  1167.  
  1168.                                                             if(Node = (struct Node *)AllocVecPooled(sizeof(struct Node) + 256,MEMF_ANY))
  1169.                                                             {
  1170.                                                                 Node -> ln_Name = (STRPTR)(Node + 1);
  1171.  
  1172.                                                                 strcpy(Node -> ln_Name,DummyBuffer);
  1173.  
  1174.                                                                 AddTail(TransferList,Node);
  1175.  
  1176.                                                                 TransferCount++;
  1177.                                                             }
  1178.                                                         }
  1179.  
  1180.                                                         UnLock(FileLock);
  1181.                                                     }
  1182.                                                 }
  1183.  
  1184.                                                 CurrentDir(OldDir);
  1185.                                             }
  1186.                                         }
  1187.  
  1188.                                         if(Handle)
  1189.                                         {
  1190.                                             TransferProcess -> pr_WindowPtr = LocalWindow;
  1191.  
  1192.                                             LT_SetAttributes(Handle,GAD_LIST,
  1193.                                                 GTLV_Labels,    TransferList,
  1194.                                             TAG_DONE);
  1195.  
  1196.                                             LT_SetAttributes(Handle,GAD_CLEAR,
  1197.                                                 GA_Disabled,    !TransferCount,
  1198.                                             TAG_DONE);
  1199.  
  1200.                                             LT_SetAttributes(Handle,UPLOAD_BINARY,
  1201.                                                 GA_Disabled,    !TransferCount,
  1202.                                             TAG_DONE);
  1203.  
  1204.                                             LT_SetAttributes(Handle,UPLOAD_TEXT,
  1205.                                                 GA_Disabled,    !TransferCount,
  1206.                                             TAG_DONE);
  1207.                                         }
  1208.                                         else
  1209.                                             TransferProcess -> pr_WindowPtr = OldPtr;
  1210.                                     }
  1211.                                     else
  1212.                                     {
  1213.                                         if(!Handle)
  1214.                                         {
  1215.                                             if(Handle = QueuePanel(NULL))
  1216.                                             {
  1217.                                                 AppWindow = AddAppWindowA(APP_WINDOW,NULL,Handle -> Window,AppPort,NULL);
  1218.  
  1219.                                                 LocalWindow = Handle -> Window;
  1220.  
  1221.                                                 WindowMask = PORTMASK(LocalWindow -> UserPort);
  1222.  
  1223.                                                 TransferProcess -> pr_WindowPtr = LocalWindow;
  1224.                                             }
  1225.                                         }
  1226.                                     }
  1227.                                 }
  1228.  
  1229.                                 ReplyMsg(AppMessage);
  1230.                             }
  1231.                         }
  1232.                     }
  1233.                     while(!Done);
  1234.  
  1235.                     if(AppIcon)
  1236.                         RemoveAppIcon(AppIcon);
  1237.  
  1238.                     if(AppWindow)
  1239.                         RemoveAppWindow(AppWindow);
  1240.  
  1241.                     if(LoadedIcon)
  1242.                         FreeDiskObject(LoadedIcon);
  1243.  
  1244.                     if(Handle)
  1245.                         LT_DeleteHandle(Handle);
  1246.  
  1247.                     while(AppMessage = (struct AppMessage *)GetMsg(AppPort))
  1248.                         ReplyMsg(AppMessage);
  1249.  
  1250.                     FreeSignal(TransferSignal);
  1251.                 }
  1252.             }
  1253.  
  1254.             DeleteMsgQueue(TransferQueue);
  1255.         }
  1256.  
  1257.         DeleteList(TransferList);
  1258.  
  1259.         TransferList = NULL;
  1260.     }
  1261.  
  1262.     Forbid();
  1263.  
  1264.     TransferProcess = NULL;
  1265.  
  1266.     Signal(ThisProcess,SIG_HANDSHAKE);
  1267. }
  1268.  
  1269.     /* CloseQueueWindow():
  1270.      *
  1271.      *    Close the queue window, wherever it may be.
  1272.      */
  1273.  
  1274. VOID
  1275. CloseQueueWindow()
  1276. {
  1277.     if(TransferProcess)
  1278.     {
  1279.         Forbid();
  1280.  
  1281.         ClrSignal(SIG_HANDSHAKE);
  1282.  
  1283.         Signal(TransferProcess,SIG_GOAWAY);
  1284.  
  1285.         Wait(SIG_HANDSHAKE);
  1286.  
  1287.         Permit();
  1288.     }
  1289. }
  1290.  
  1291.     /* DeleteQueueProcess():
  1292.      *
  1293.      *    Terminate the queue handler process.
  1294.      */
  1295.  
  1296. VOID
  1297. DeleteQueueProcess()
  1298. {
  1299.     if(TransferProcess)
  1300.     {
  1301.         Forbid();
  1302.  
  1303.         ClrSignal(SIG_HANDSHAKE);
  1304.  
  1305.         Signal(TransferProcess,SIG_KILL);
  1306.  
  1307.         Wait(SIG_HANDSHAKE);
  1308.  
  1309.         Permit();
  1310.     }
  1311. }
  1312.  
  1313.     /* CreateQueueProcess():
  1314.      *
  1315.      *    Create the queue handler process, if it's still around
  1316.      *    bring it to the front.
  1317.      */
  1318.  
  1319. BOOLEAN
  1320. CreateQueueProcess()
  1321. {
  1322.     if(!TransferProcess)
  1323.     {
  1324.         Forbid();
  1325.  
  1326.         if(CreateNewProcTags(
  1327.             NP_Entry,    QueueEntry,
  1328.             NP_Name,    "term Upload process",
  1329.             NP_Priority,    SysBase -> ThisTask -> tc_Node . ln_Pri,
  1330.             NP_StackSize,    6144,
  1331.             NP_WindowPtr,    NULL,
  1332.         TAG_DONE))
  1333.         {
  1334.             ClrSignal(SIG_HANDSHAKE);
  1335.  
  1336.             Wait(SIG_HANDSHAKE);
  1337.         }
  1338.  
  1339.         Permit();
  1340.     }
  1341.     else
  1342.         Signal(TransferProcess,SIG_SHOW);
  1343.  
  1344.     return((BOOLEAN)(TransferProcess != NULL));
  1345. }
  1346.  
  1347. STATIC VOID __stdargs
  1348. LocalMsgDestructor(struct DataMsg *Item)
  1349. {
  1350.     Signal(ThisProcess,SIGBREAKF_CTRL_F);
  1351. }
  1352.  
  1353.     /* GetUploadList():
  1354.      *
  1355.      *    Copy the current upload list and return it.
  1356.      */
  1357.  
  1358. struct List *
  1359. GetUploadList()
  1360. {
  1361.     if(TransferProcess)
  1362.     {
  1363.         struct DataMsg Msg;
  1364.  
  1365.         InitMsgItem(&Msg,LocalMsgDestructor);
  1366.  
  1367.         Msg . Type = TRANSFERMSG_GET_LIST;
  1368.  
  1369.         ClrSignal(SIGBREAKF_CTRL_F);
  1370.  
  1371.         PutMsgItem(TransferQueue,(struct MsgItem *)&Msg);
  1372.  
  1373.         Wait(SIGBREAKF_CTRL_F);
  1374.  
  1375.         return((struct List *)Msg . Data);
  1376.     }
  1377.     else
  1378.         return(NULL);
  1379. }
  1380.  
  1381.     /* CheckUpload():
  1382.      *
  1383.      *    Check if there is anything in the upload list.
  1384.      */
  1385.  
  1386. BOOLEAN
  1387. CheckUpload()
  1388. {
  1389.     if(TransferProcess)
  1390.     {
  1391.         struct DataMsg Msg;
  1392.  
  1393.         InitMsgItem(&Msg,LocalMsgDestructor);
  1394.  
  1395.         Msg . Type = TRANSFERMSG_CHECK_LIST;
  1396.  
  1397.         ClrSignal(SIGBREAKF_CTRL_F);
  1398.  
  1399.         PutMsgItem(TransferQueue,(struct MsgItem *)&Msg);
  1400.  
  1401.         Wait(SIGBREAKF_CTRL_F);
  1402.  
  1403.         return((BOOLEAN)Msg . Size);
  1404.     }
  1405.     else
  1406.         return(FALSE);
  1407. }
  1408.  
  1409.     /* StartUpload(UBYTE Type):
  1410.      *
  1411.      *    Start an upload the standard way.
  1412.      */
  1413.  
  1414. VOID __regargs
  1415. StartUpload(UBYTE Type)
  1416. {
  1417.     if(TransferProcess)
  1418.     {
  1419.         struct DataMsg Msg;
  1420.  
  1421.         SetQueueDiscard(SpecialQueue,FALSE);
  1422.  
  1423.         InitMsgItem(&Msg,LocalMsgDestructor);
  1424.  
  1425.         Msg . Type = TRANSFERMSG_UPLOAD;
  1426.         Msg . Size = Type;
  1427.  
  1428.         ClrSignal(SIGBREAKF_CTRL_F);
  1429.  
  1430.         PutMsgItem(TransferQueue,(struct MsgItem *)&Msg);
  1431.  
  1432.         Wait(SIGBREAKF_CTRL_F);
  1433.     }
  1434. }
  1435.  
  1436.     /* ToggleUploadQueueIcon():
  1437.      *
  1438.      *    Turn the upload queue appicon on or off.
  1439.      */
  1440.  
  1441. VOID __regargs
  1442. ToggleUploadQueueIcon(BOOL Mode)
  1443. {
  1444.     if(TransferProcess)
  1445.     {
  1446.         struct DataMsg Msg;
  1447.  
  1448.         InitMsgItem(&Msg,LocalMsgDestructor);
  1449.  
  1450.         Msg . Type = TRANSFERMSG_TOGGLE_ICON;
  1451.         Msg . Size = Mode;
  1452.  
  1453.         ClrSignal(SIGBREAKF_CTRL_F);
  1454.  
  1455.         PutMsgItem(TransferQueue,(struct MsgItem *)&Msg);
  1456.  
  1457.         Wait(SIGBREAKF_CTRL_F);
  1458.     }
  1459. }
  1460.